<?php


namespace App\Command\Tools;


use App\Web\Model\CaseFlow;
use EchoPHP\Console\Command;

class GenerateFlowList extends Command {

    protected $signature = "tools:generateFlowList";
    protected $description = '生成流程js文件';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct() {
        parent::__construct();
    }

    /*
     * 生成过程
     */
    public function handle() {
        $caseFlowList = config('app.global_caseflow');
        if (!is_file($caseFlowList)) {
            $this->output->error('字典文件未定义');
            exit();
        }
        $caseFlow = include $caseFlowList;
        $jsonFilePath = config('app.global_caseflow_json');
        file_put_contents($jsonFilePath, json_encode($caseFlow));
        $this->output->success('json文件生成成功');
    }
}